from oneconvert.utils import importutils

_DATA_SOURCE_MAPPING = {
    'csv': 'oneconvert.datasource.json.ds_csv.CsvDataSource',
    'json': 'oneconvert.datasource.json.ds_json.JsonDataSource',
    'yaml': 'oneconvert.datasource.json.ds_yaml.YamlDataSource',
    'properties': 'oneconvert.datasource.json.ds_properties.PropertiesDataSource',
    'xlsx': 'oneconvert.datasource.json.ds_excel.ExcelDataSource',
    'xls': 'oneconvert.datasource.json.ds_excel.ExcelDataSource',
}


def get_data_source(data_format, uri):
    if data_format not in _DATA_SOURCE_MAPPING:
        raise ValueError(f"data format '{data_format}' not supported")

    return importutils.import_class(_DATA_SOURCE_MAPPING[data_format])(uri)
